package com.htcms.dao;

import java.util.ArrayList;
import java.util.List;

import org.hibernate.criterion.Order;

import com.htcms.base.HibernateBaseDao;
import com.htcms.bean.Admin;
import com.htcms.bean.Message;
import com.htcms.utils.Pager;

public class AdminDAO  extends HibernateBaseDao{
	public Admin getAdminByName(String name){
		String hql="from Admin admin where admin.username=?";
		Object result=this.uniqueResult(hql,name);
		if(null!=result)
			return (Admin)result;
		else
			return null;
	}
	
	public void saveAdmin(Admin admin){
		this.getHibernateTemplate().saveOrUpdate(admin);
	}
	
	public void findListByPage(Pager pager,Admin admin){
		List criterions = new ArrayList();
		List orders = new ArrayList();
		orders.add(Order.desc("id"));
		this.findPageByCriteria(pager, Admin.class, criterions, orders);
	}
}
